package com.xianxing.common.handler;

import com.xianxing.common.util.Response;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理类
 * @program: xianxing
 * @description:
 * @author: Mr.Ren
 * @create: 2020-03-09 14:16
 **/

@ControllerAdvice//声明这是一个增强类
@Configuration
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Response error(Exception e){
        e.printStackTrace();
        return Response.FAIL("当前网络繁忙，请稍后重试！");
    }
}
